public class test {
    public int removeDuplicates(int[] nums) {
        if(nums.length == 0){
            return 0;
        }
        int slow = 2;
        int fast = 2;
        while(fast < nums.length){
            if(nums[fast] != nums[slow - 2]){
                nums[slow] = nums[fast];
                slow++;
            }
            fast++;
        }
        return slow;
    }
}
